package metu.tespit.session.schedule;

import java.util.List;

import javax.persistence.EntityManager;

import metu.tespit.entity.course.Activity;
import metu.tespit.session.course.CourseHome;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;

/**
 
 * @created May 30, 2012
 */
@Name("submissionActivityForCourse")
public class SubmissionActivityForCourse {

	
	@In
	private EntityManager entityManager;
	
	@In
	private CourseHome courseHome;
	
	@SuppressWarnings("unchecked")
	public List<Activity> getResultList(){
		return (List<Activity>)entityManager.createQuery("select act from Activity act where act.schedule.course.id=:id " +
				"and act.submissionActivity=true order by act.dueDate desc").setParameter("id", courseHome.getInstance().getId())
				.getResultList();
	}
}
